const fs = require('fs');
const parser = require('./parser')
const deparser = require('./deParser')
const jsDom = require('jsdom')
const { JSDOM } = jsDom

var rs = fs.createReadStream(__dirname + '/music_text', { flag: 'r', encoding: 'utf8' })
// var ws = fs.createWriteStream(__dirname + '/music_text1')

var rsDe = fs.createReadStream(__dirname + '/detest.html', { flags: 'r', encoding: 'utf8' })

// rs.on('data', function (data) {
//   let content = Buffer.from(data).toString('base64')
//   parser(content)
// })

rsDe.on('data', function (data) {
  let content = Buffer.from(data).toString('base64')
  let preContent = Buffer.from(content, 'base64').toString()
  let dom = new JSDOM(`<div></div>`)
  let htmlDom = dom.window.document.documentElement
  htmlDom.innerHTML = preContent
  deparser(htmlDom)
})



